//
//  TestActorDownloadApp.swift
//  TestActorDownload
//
//  Created by rolodestar on 2025/6/13.
//

import SwiftUI
import SwiftData

@main
struct TestActorDownloadApp: App {
    
    var sharedModelContainer: ModelContainer = {
        let schema = Schema([
            Item.self,
            DownloadDataModel.self,
        ])
        let modelConfiguration = ModelConfiguration(schema: schema, isStoredInMemoryOnly: false)
       
        do {
            let container =  try ModelContainer(for: schema, configurations: [modelConfiguration])
//            let shared =  DownloadManagerActor.createShared(modelContext: container.mainContext)
            return container
        } catch {
            fatalError("Could not create ModelContainer: \(error)")
        }
    }()
    let manager = DownloadManager.shared
    
    var body: some Scene {
        WindowGroup {
            ContentView()
        }
        .modelContainer(sharedModelContainer)
        .environmentObject(manager)
    }
    

//    func application(_ application: UIApplication,
//                     handleEventsForBackgroundURLSession identifier: String,
//                     completionHandler: @escaping () -> Void) {
//        backgroundCompletionHandler = completionHandler // 暂存回调
//    }
}
